<!--<!DOCTYPE html>-->
<!--<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">-->
<!--<head>-->
<!--    <meta charset="UTF-8">-->
<!--    <title>供应商信息管理</title>-->
<!--    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}" media="all">-->
<!--    <link rel="stylesheet" th:href="@{/static/admin/style.css}" media="all">-->
<!--    <script type="text/html" id="indexTpl">-->
<!--        {{d.LAY_TABLE_INDEX + 1}}-->
<!--    </script>-->
<!--</head>-->
<!--<body class="layui-layout-body">-->
<!--&lt;!&ndash;自适应一种宽度&ndash;&gt;-->
<!--<div class="layui-fluid">-->
<!--    &lt;!&ndash;  行的宽度  &ndash;&gt;-->
<!--    <div class="layui-row layui-col-space15">-->
<!--        &lt;!&ndash;   列的宽度     &ndash;&gt;-->
<!--        <div class="layui-col-md12">-->
<!--            &lt;!&ndash;   内容以卡片的形式          &ndash;&gt;-->
<!--            <div class="layui-card">-->
<!--                <div class="layui-card-header">供应商信息列表</div>-->
<!--                <div class="layui-card-body">-->
<!--                    &lt;!&ndash;  主体   &ndash;&gt;-->
<!--                    <table class="layui-hide" id="main-table" lay-filter="main-table"></table>-->
<!--                    &lt;!&ndash;       添加个搜索顺带实现模糊查询     符号代表+号        &ndash;&gt;-->
<!--                    <script type="text/html" id="toolbarDemo">-->
<!--                        <span class="layui-inline" lay-event="add"><i class="layui-icon">&#xe654;</i></span>-->
<!--                        <span class="layui-inline" style="width: 240px;">-->
<!--                            <input class="layui-input" name="param" id="param" placeholder="根据药品名称查询"-->
<!--                                   autocomplete="off">-->
<!--                        </span>-->
<!--                        <span class="layui-btn layui-btn-sm layui-bg-red" lay-event="querySearch">-->
<!--                           <i class="layui-icon">&#xe615;</i>查询-->
<!--                        </span>-->
<!--                    </script>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
<!--    </div>-->
<!--</div>-->
<!--<script th:src="@{/static/layui/layui.js}"></script>-->
<!--<script>-->
<!--    layui.use(['table', 'form'], function () {-->
<!--        var $ = layui.$;-->
<!--        var table = layui.table;-->
<!--        //区域获取-->
<!--        table.render({-->
<!--            elem: '#main-table',-->
<!--            height: 650,-->
<!--            url: '/supplier/supplierQueryPage',-->
<!--            method: 'post',-->
<!--            page: true,-->
<!--            id: 'table-load',//供其回调用-->
<!--            //哪些列-->
<!--            toolbar: '#toolbarDemo',-->
<!--            cols: [-->
<!--                [-->
<!--                    {title: '序号', templet: '#indexTpl', width: 60, align: 'center'},-->
<!--                    {field: 'name', title: '供应商名称', align: 'center', width: 250},-->
<!--                    {field: 'content', title: '描述', align: 'center', width: 400},-->
<!--                    {-->
<!--                        field: 'createtime', title: '创建时间', align: 'center', width: 250,-->
<!--                        templet: "<div>{{layui.util.toDateString(d.createtime,'yyyy-MM-dd HH:mm:ss')}}</div>"-->
<!--                    }-->
<!--                ]-->
<!--            ]-->

<!--        });-->
<!--        //监听头工具栏事件-->
<!--        table.on('toolbar(main-table)', function (obj) {-->
<!--            switch (obj.event) {-->
<!--                //新增标签-->
<!--                case 'add':-->
<!--                    layer.open({-->
<!--                        type: 2,-->
<!--                        title: '新增供应商信息',-->
<!--                        content: '/supplier/supplierPage',-->
<!--                        shade: [0.8, '#393d49'],//透明度-->
<!--                        area: ['600px', '400px'],-->
<!--                        btn: ['确定', '取消'],-->
<!--                        // yes: function (index, layero) {-->
<!--                        //     var iframeWindow = window['layui-layer-iframe' + index];-->
<!--                        //     var submit = layero.find('iframe').contents().find("#LAY-front-submit");-->
<!--                        //     //监听提交-->
<!--                        //     iframeWindow.layui.form.on('submit(#LAY-front-submit)', function (data) {-->
<!--                        //         var field = data.field;-->
<!--                        //         $.ajax(-->
<!--                        //             {-->
<!--                        //                 url:'/supplier/supplierAdd',-->
<!--                        //                 data: field,-->
<!--                        //                 async: false,-->
<!--                        //                 cache: false,-->
<!--                        //                 success: function(str){-->
<!--                        //                     if(str.code === 0){-->
<!--                        //                         table.reload('table-load');-->
<!--                        //                     }-->
<!--                        //                     layer.msg(str.msg,{icon:str.icon,anim:str.anim});-->
<!--                        //                 }-->
<!--                        //             }-->
<!--                        //         );-->
<!--                        //         layer.close(index);//关闭弹窗-->
<!--                        //     });-->
<!--                        //     submit.trigger('click');-->
<!--                        // },-->
<!--                        yes:function (index,layero) {-->
<!--                            var iframeWindow = window['layui-layer-iframe'+index];-->
<!--                            var submit = layero.find('iframe').contents().find("#LAY-front-submit");-->
<!--                            //监听提交-->
<!--                            iframeWindow.layui.form.on('submit(LAY-front-submit)',function (data) {-->
<!--                                var field  = data.field;-->
<!--                                $.ajax({-->
<!--                                    url: '/supplier/supplierAdd',-->
<!--                                    data: field,-->
<!--                                    async: false,-->
<!--                                    cache: false,-->
<!--                                    success: function (str) {-->
<!--                                        if(str.code === 0){-->
<!--                                            table.reload('table-load');-->
<!--                                        }-->
<!--                                        layer.msg(str.msg,{icon:str.icon,anim:str.anim});-->
<!--                                    }-->
<!--                                });-->
<!--                                layer.close(index);     //关闭弹层-->
<!--                            });-->
<!--                            submit.trigger('click');-->
<!--                        },-->
<!--                        success: function (layero, index) {-->


<!--                        }-->

<!--                    });-->
<!--                    break;-->
<!--                case 'querySearch' :-->
<!--                    var param = $('#param').val();-->
<!--                    table.reload('table-load', {-->
<!--                        where: {-->
<!--                            param: param-->
<!--                        }-->
<!--                    });-->
<!--                    $('#param').val(param);-->
<!--                    break;-->

<!--            }-->
<!--        });-->
<!--    });-->
<!--</script>-->
<!--</body>-->
<!--</html>-->
<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>供应商信息管理</title>
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/static/admin/style.css}" media="all">
    <script type="text/html" id="indexTpl">
        {{d.LAY_TABLE_INDEX+1}}
    </script>
</head>
<body class="layui-layout-body">
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">供应商信息列表</div>
                <div class="layui-card-body">
                    <table class="layui-hide" id="main-table" lay-filter="main-table"></table>
                    <script type="text/html" id="toolbarDemo">
                        <span class="layui-inline" lay-event="add"><i class="layui-icon">&#xe654;</i> </span>
                        <span class="layui-inline" style="width: 240px;">
                                <input class="layui-input" name="param" id="param" placeholder="根据药品名称查询" autocomplete="off">
                            </span>
                        <span class="layui-btn layui-btn-sm layui-bg-red" lay-event="querySearch">
                                <i class="layui-icon">&#xe615;</i>查询
                            </span>
                    </script>
                    <script type="text/html" id="barDemo">
                        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/static/layui/layui.js}"></script>
<script>
    layui.use(['table','form'],function () {
        var $ = layui.$;
        var table = layui.table;
        table.render({
            elem: '#main-table',
            height: 650,
            url: '/supplier/supplierQueryPage',
            method: 'POST',
            page: true,
            id: 'table-load',
            toolbar: '#toolbarDemo',
            cols: [
                [
                    {title: '序号',templet: '#indexTpl',width: 60,align:'center'},
                    {field:'name',title:'供应商名称',algin:'center',width:350},
                    {field:'content',title:'描述',algin:'center',width:600},
                    {field:'createtime',title:'创建时间',algin:'center',width:250,
                        templet:"<div>{{layui.util.toDateString(d.createtime,'yyyy-MM-dd HH:mm:ss')}}</div>"},
                    {title:'操作',align:'center',toolbar:'#barDemo',fixed:'right'}
                ]
            ]
        });

        //监听头工具栏事件
        table.on('toolbar(main-table)',function (obj) {
            switch (obj.event) {
                case 'add':
                    layer.open({
                        type: 2,
                        title: '新增供应商信息',
                        content: '/supplier/supplierPage',
                        shade:[0.8,'#393d49'],
                        area:['600px','400px'],
                        btn:['确定','取消'],
                        yes:function (index,layero) {
                            var iframeWindow = window['layui-layer-iframe'+index];
                            var submit = layero.find('iframe').contents().find("#LAY-front-submit");
                            //监听提交
                            iframeWindow.layui.form.on('submit(LAY-front-submit)',function (data) {
                                var field = data.field;
                                $.ajax({
                                    url: '/supplier/supplierAdd',
                                    data: field,
                                    async: false,
                                    cache: false,
                                    success: function (str) {
                                        if(str.code === 0){
                                            table.reload('table-load');
                                        }
                                        layer.msg(str.msg,{icon:str.icon,anim:str.anim});
                                    }
                                });
                                layer.close(index);     //关闭弹层
                            });
                            submit.trigger('click');
                        },
                        success:function (layero,index) {

                        }
                    });
                    break;
                case 'querySearch':
                    var param = $('#param').val();
                    table.reload('table-load',{
                        where: {
                            param: param
                        }
                    });
                    $('#param').val(param);
                    break;
            }
        });

        //监听编辑、删除
        table.on('tool(main-table)',function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'edit':
                    layer.open({
                        type: 2,
                        title: '编辑供应商信息',
                        content: '/supplier/supplierQueryById?id=' +data.id,
                        shade:[0.8,'#393d49'],
                        area:['600px','400px'],
                        btn:['确定','取消'],
                        yes:function (index,layero) {
                            var iframeWindow = window['layui-layer-iframe'+index];
                            var submit = layero.find('iframe').contents().find("#LAY-front-submit");
                            //监听提交
                            iframeWindow.layui.form.on('submit(LAY-front-submit)',function (data) {
                                var field = data.field;
                                $.ajax({
                                    url: '/supplier/supplierEdit',
                                    data: field,
                                    async: false,
                                    cache: false,
                                    success: function (str) {
                                        if(str.code === 0){
                                            table.reload('table-load');
                                        }
                                        layer.msg(str.msg,{icon:str.icon,anim:str.anim});
                                    }
                                });
                                layer.close(index);     //关闭弹层
                            });
                            submit.trigger('click');
                        },
                        success:function (layero,index) {

                        }
                    });
                    break;
                case 'del':
                    layer.confirm('确认要删除吗？',function (index) {
                        $.ajax({
                            url: '/supplier/supplierDelById?id=' +data.id,
                            data: null,
                            async: false,
                            cache: false,
                            success: function (str) {
                                table.reload('table-load');
                                layer.msg(str.msg,{icon:str.icon,anim:str.anim});
                            }
                        });
                    })
                    break;
            }
        });
    });
</script>
</body>
</html>
















